<template>
	<view class="index">
		<view class="item f-x-bt  mb10 c3" v-for="(item,index) in list" :key="index" @click="choose(item)">
			<view class="f-s ">
				<text>{{item.store_name}}</text>
				<u-tag v-if="item.realtimeState==1" text="营业" type="success" plain shape="circle"></u-tag>
				<u-tag v-else-if="item.realtimeState==2" text="繁忙" type="warning" plain shape="circle"></u-tag>
				<u-tag v-else-if="item.realtimeState==3" text="休息中" type="error" plain shape="circle"></u-tag>
				<u-tag v-else-if="item.realtimeState==4" text="接受预定" plain shape="circle"></u-tag>
				<u-tag v-if="item.isolate==1" text="独立门店" plain></u-tag>
				<u-tag v-else text="品牌门店" type="success" plain></u-tag>
			</view>
			<u-icon size="20" color="#999" name="arrow-right"></u-icon>
		</view>
	</view>
</template>

<script>
	import {
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				subColor: uni.getStorageSync('subject_color'),
				list: [],
			}
		},
		async onLoad() {
			this.fetchData()
		},
		methods: {
			...mapMutations(["setStoreId"]),
			async fetchData() {
				await this.beg.request({
					url: '/admin/store.Store/index',
					method: 'post',
					data: {
						limit: 10,
						page: 1,
						store_name: ""
					},
				}).then(res => {
					this.list = res.data.data
					console.log(this.list)
					this.total = res.data.count
				})
			},
			async choose(v) {
				getApp().globalData.storeName = v.name
				await this.setStoreId(v)
				uni.$emit('socketInit');
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.index {
		padding: 24upx;
		background-color: #f6f6f6;

		.item {
			width: 100%;
			border-radius: 7px;
			padding: 35upx 24upx;
			background-color: #fff;

			/deep/.u-tag--medium {
				margin-left: 8px;
				height: 18px;
				line-height: 18px;
				padding: 0 5px;
			}

			/deep/.u-tag__text--medium {
				font-size: 12px;
			}
		}
	}
</style>